Skip to content

Conversation

@georgeweiler
Copy link
Contributor

@georgeweiler georgeweiler commented Jan 23, 2026

Explanation

Reorganizes RampsController initialization to separate critical startup data from region-specific data fetching. This change improves app startup performance by deferring non-essential data fetching until the wallet home page loads.

Additionally, there are interface updates as the API now returns countries with supported: { buy: true, sell: true }.

Changes

  • init() method: Now only fetches geolocation and countries (24h TTL) on engine instantiation
  • hydrateState() method: New method that fetches providers and tokens for the user's region, called on wallet home page load
  • Countries state: Added countries: Country[] to controller state with 24 hour TTL caching
  • getCountries(): Removed action parameter - API now returns buy/sell support info in a single response
  • setUserRegion(): Refactored to use countries from state instead of fetching them
  • SupportedActions type: New type { buy: boolean; sell: boolean } for region support info
  • Country.supported / State.supported: Changed from boolean to SupportedActions object

Benefits

  • Faster app startup - only essential data (geolocation) fetched during initialization
  • Better separation of concerns - region-specific data fetched when needed
  • Improved caching - countries stored in state with 24h TTL, reducing redundant API calls
  • Cleaner architecture - prepares for mobile integration where hydrateState() will be called on wallet page load
  • Fixes bug where setUserRegion() could fail if sell countries were fetched after init

References

https://consensyssoftware.atlassian.net/browse/TRAM-3230

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Reorganizes ramps initialization and country support handling, with new state and API types.

  • Init split: init() now only fetches geolocation and getCountries(); new hydrateState() defers fetching tokens/providers until later
  • Countries state + caching: Adds countries: Country[] persisted in controller state (24h TTL via request cache); getCountries() saves to state
  • BREAKING type changes: Country.supported/State.supported changed from boolean to SupportedActions { buy; sell }; exported SupportedActions
  • BREAKING API change: getCountries() no longer accepts an action parameter; service endpoint call updated and filtering logic adjusted to buy/sell support
  • Controller changes: setUserRegion() now uses countries from state and triggers fetches; added internal cleanup; removed updateUserRegion() and its trigger; updated trigger method signatures
  • Tests/exports: Updated tests, snapshots, and exports to match new behavior/types

Written by Cursor Bugbot for commit 556edd5. This will update automatically on new commits. Configure here.

…geolocation and countries, add countries to state, and create hydrateStore() for providers/tokens
@georgeweiler georgeweiler marked this pull request as ready for review January 23, 2026 03:11
@georgeweiler georgeweiler requested review from a team as code owners January 23, 2026 03:11
@georgeweiler
Copy link
Contributor Author

cursor review

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@georgeweiler georgeweiler changed the title feat: Reorganize RampsController initialization feat(ramps): Reorganize RampsController initialization Jan 23, 2026
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

@georgeweiler georgeweiler added this pull request to the merge queue Jan 23, 2026
Merged via the queue into main with commit bf4b52c Jan 23, 2026
302 checks passed
@georgeweiler georgeweiler deleted the TRAM-3230-controller-init-reorg branch January 23, 2026 22:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants